home *** CD-ROM | disk | FTP | other *** search
/ PC Player 2004 May / pc player 2004-05.iso / Demos / FarCry / Data1.cab / _B3F27BC55EDF4CAC8A446890D8D8331D < prev    next >
Encoding:
Text File  |  2004-01-06  |  2.2 KB  |  84 lines

  1. // ===============================================================
  2. // Vertex Program: Outdoor water refraction
  3. // Description: used in outdoor refractive water
  4. // Last Update: 28/08/2003
  5. // Coder: Tiago Sousa
  6. // ===============================================================
  7.  
  8. #include "../CGVPMacro.csi"
  9.  
  10. VertAttributes { POSITION_3 PRIM_COLOR }
  11.  
  12. Projected
  13.  
  14. // setup vertex components
  15. MainInput
  16. {
  17.   // common model view matrix
  18.   VIEWPROJ_MATRIX,
  19.   uniform float4   CameraPos,      
  20.   uniform float4   TexGenRipple0,
  21.   uniform float4   TexGenRipple1,
  22.   uniform float4   TexShiftRipple,
  23.   uniform float4   TexDetailScale,     
  24.   uniform float4   ScreenSize
  25. }
  26.  
  27. DeclarationsScript
  28. {
  29.   // vertex input
  30.   IN_C0
  31.   // vertex output
  32.   OUT_T0_T1_C0
  33. }
  34.  
  35. // output vertex position
  36. PositionScript = PosCommon
  37.  
  38. CoreScript
  39. {    
  40.   float4 vHPos = mul(ModelViewProj, vPos);     
  41.  
  42. #ifdef D3D
  43.   #ifdef PROJECTEDENVBUMP
  44.   // optimized perspective correct projection
  45.   OUT.Tex1.xz = (vHPos.xz  + vHPos.w)*0.5;    
  46.   OUT.Tex1.y =  (-vHPos.y  + vHPos.w)*0.5;      
  47.   OUT.Tex1.w   = vHPos.w;      
  48.   #endif
  49.   #ifdef OTHER
  50.   // have to use per-vertex projection..  
  51.   vHPos.y = -vHPos.y;
  52.     OUT.Tex1.xy = (vHPos.xy/vHPos.w  + 1)*0.5;          
  53.   #endif
  54. #endif
  55.  
  56. #ifdef OPENGL        
  57.   #ifdef PROJECTEDENVBUMP
  58.   // optimized perspective correct projection
  59.   OUT.Tex1.xz = (vHPos.xz  + vHPos.w)*0.5*ScreenSize.x;    
  60.   OUT.Tex1.y =  (vHPos.y  + vHPos.w)*0.5*ScreenSize.y;      
  61.   OUT.Tex1.w   = vHPos.w;      
  62.   #endif
  63.   #ifdef OTHER
  64.   // have to use per-vertex projection..
  65.     OUT.Tex1.xy = (vHPos.xy/vHPos.w  + 1)*0.5*ScreenSize.xy;          
  66.     #endif
  67. #endif
  68.         
  69.   // output texture coordinates  
  70.   float2 vTex;
  71.   vTex.x = dot(vPos, TexGenRipple0);
  72.   vTex.y = dot(vPos, TexGenRipple1);
  73.   vTex.xy= (vTex.xy+(TexDetailScale.w*TexShiftRipple.zw))*TexDetailScale.xy;
  74.   OUT.Tex0.xy = vTex.xy;
  75.             
  76.   // output color and fresnel term hack  
  77.   //float3 eyeVec = normalize(CameraPos.xyz - vPos.xyz);  
  78.   //float3 fNormal=float3(0,0,1);
  79.   //float fDot= abs(dot(eyeVec, fNormal));      
  80.   OUT.Color.w =IN.Color.w; //fDot*2.0*(1-0.05*vHPos.w);
  81.    
  82.   return OUT;
  83. }
  84.